#lang scheme

;; Choose one of the list randomly
(define (one-of list)
  (if (or (empty? (cdr list))
          (= (random 2) 0))
      (car list)
      (one-of (cdr list))))

;; A sentence is made up with:
;; <object> -- <verb> -- <subject>
(define (sentence)
  (list (object) (verb) (subject)))

(define (object)
  (one-of '(MAN WOMAN BOY GIRL CAT DOG)))

(define (verb)
  (one-of '(IS LIKES EATS BEATS)))

(define (subject)
  (one-of '(MAN WOMAN BOY GIRL CAT DOG)))

;; if you would add more support for the generater
;; like add adjective words or other words to
;; beautify the sentence.
;; (define (object)
;;   (list (adjective) (noun))

(define (noun)
  (one-of '(MAN WOMAN BOY GIRL CAT DOG)))

(define (adjective)
  (one-of '(LUCKY SAD HAPPY)))

(define (adverb)
  (one-of '(SERIOUSLY CONTIDENTLY)))

(define (object-re)
  (list (adjective) (noun)))

(define (verbs)
  (one-of '(IS LIKES EATS BEATS)))

(define (subject-re)
  (list (adjective) (noun)))

(define (verb-re)
  (list (verbs) (adverb)))

(define (sentence-re)
  (flatten (list (object-re) (verb-re) (subject-re))))

;; However, you might find that this program is hard to maintain
;; and if you want to add more functions to the program, it would
;; be a difficult thing as you go along.
;; so what if you change it into another way? 
